package com.ruoyi.system.api;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.AppSystemPushService;

import io.swagger.annotations.Api;

@RestController
@RequestMapping("/api/v1/pushMsg")
@Api(tags = "【APP】系统推送记录相关接口")
@CrossOrigin
public class AppSystemPushController {

	@Autowired
	private AppSystemPushService appSystemPushService;
	
	/**
	 * 	获取系统消息
	 * @param pageNo		开始页
	 * @param type			1=系统消息 2=订单消息
	 * @param request
	 * @return
	 */
	@GetMapping(value = "/getSystemMsg")
	public AjaxResult getSystemMsg(Integer pageNo,Integer type,HttpServletRequest request) {
		if(null == type) {
			type = 1;
		}
		if(null == pageNo) {
			pageNo = 1;
		}
		return appSystemPushService.getSystemMsg(pageNo,type,request);
	}
	
	/**
	 * 	获取最新一条系统消息
	 * @return
	 */
	@GetMapping(value = "/getLatestMsg")
	public AjaxResult getLatestMsg() {
		return appSystemPushService.getLatestMsg();
	}
	
	
	/**
	 * 	获取官方消息
	 * @param pageNo		开始页
	 * @param request
	 * @return
	 */
	@GetMapping(value = "/getOfficialMsg")
	public AjaxResult getOfficialMsg(Integer pageNo,HttpServletRequest request) {
		return appSystemPushService.getOfficialMsg(pageNo,request);
	}
}
